<?php 
function subwords($words,$num){

	$total_num = str_word_count($words); 

	if($total_num <= $num){  
		return $words;
	}else{
		$pattern = '/([\S]+?[ ]+){'.$num.'}/';
		preg_match($pattern, $words, $out);
		return $out[0].'...'; 
	}
}

?>
<?php $posts = $this->getPosts(); ?>
<div class="faq_left">
               <div class="title">Frequently Asked Questions</div>      
               <div class="questionlist">
                 <ul>
                   <?php foreach ($posts as $post):?>
                   <li onclick="faq_list_select('<?php echo $post->getPostId()?>')"><a href="<?php echo '#'.$post->getTitle()?>"><?php echo $post->getTitle()?></a></li>
                   <?php endforeach;?>
				 </ul>
               </div>
         
        </div> 
        <div class="faq_right">
           <div class="question">Answers</div>
           
           <?php foreach ($posts as $post):?>
           <a name="<?php echo $post->getTitle()?>"></a> 
           <div  class="qeslist">
           <!--<div class="list_bg1"><img src="images/faq_list_bg_content.gif"/></div>-->
             <div id="box_topline_<?php echo $post->getPostId()?>" class="box_topline"><img src="<?php echo $this->getSkinUrl()?>images/faq_list_topbg.gif"/></div>
             <div id="list_content_<?php echo $post->getPostId()?>" class="list_content">
               <div id="title_<?php echo $post->getPostId()?>" class="title"><?php echo $post->getTitle()?></div>
               <div  id="answers_<?php echo $post->getPostId()?>" class="answers"><?php echo $post->getPostContent()?></div>
             </div>
             <div id="box_bottomline_<?php echo $post->getPostId()?>" class="box_bottomline"><img src="<?php echo $this->getSkinUrl()?>images/faq_list_bottombg.gif"/></div>
           </div>
 		  <?php endforeach;?>
           
           
</div>
